using System;
using Microsoft.AspNetCore.Mvc;
using netcoreApi.Dto;
using netcoreApi.service;

namespace netcoreApi.Controller
{
    /// <summary>
    /// 测试类
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class TestController
    {
        ISingleService single { get; set; }
        IScopeService scope { get; set; }
        IScopeService scope1 { get; set; }
        ITransientService transient { get; set; }
        public TestController(ISingleService single, IScopeService scope, IScopeService scope1, ITransientService transient)
        {
            this.single = single;
            this.scope = scope;
            this.scope1 = scope1;
            this.transient = transient;
        }

        /// <summary>
        /// 获取字符串
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        [HttpGet]
        public string HelloIndex(string str)
        {
            return str + "sdcc";
        }

        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public User GetUser(User user)
        {
            return user;
        }

        [HttpGet]
        public void Test()
        {
            Console.WriteLine("single:"+single.GetHashCode());
            Console.WriteLine("scope:"+scope.GetHashCode());
            Console.WriteLine("scope1:"+scope1.GetHashCode());
            Console.WriteLine("transient:"+transient.GetHashCode());
            Console.WriteLine("--------------------------------------------------");
        }
    }
}